/**
 * Created by Administrator on 2018/9/26 0026.
 */
mini.parse();
//得到树
var tree = mini.get("leftTree");
function activeTab(item) {
    var tabs = mini.get("mainTabs");

    var tab = tree.getTab(item.id);
    if (!tab) {
        tab = { name: item.id, title: item.text, url: item.url, iconCls: item.iconCls, showCloseButton: true };
        tab = tabs.addTab(tab);
    }
    tabs.activeTab(tab);
}

function showTab(node) {
    var tabs = mini.get("mainTabs");
    console.log(tabs)
    var id = "tab$" + node.id;
    var tab = tabs.getTab(id);
    if (!tab) {
        tab = {};
        tab._nodeid = node.id;
        tab.name = id;
        tab.title = node.text;
        tab.showCloseButton = true;
        //这里拼接了url，实际项目，应该从后台直接获得完整的url地址
        tab.url = mini_JSPath + "../../docs/api/" + node.id + ".html";
        //tab.url="../pages/groupRun.html";

        tabs.addTab(tab);
    }
    tabs.activeTab(tab);
}

function onNodeSelect(e) {

    var node = e.node;
    var isLeaf = e.isLeaf;

    if (isLeaf) {
        showTab(node);
    }
}


function onClick(e) {
    var text = this.getText();
    alert(text);
}
//function onQuickClick(e) {
//    tree.expandPath("datagrid");
//    tree.selectNode("datagrid");
//}
//
//function onTabsActiveChanged(e) {
//    var tabs = e.sender;
//    var tab = tabs.getActiveTab();
//    if (tab && tab._nodeid) {
//
//        var node = tree.getNode(tab._nodeid);
//        if (node && !tree.isSelectedNode(node)) {
//            tree.selectNode(node);
//        }
//    }
//}
